package ce.com.cenewbluesdk;

/**
 * Created by Administrator on 2016/11/8 0008.
 */
public class CEBC {

    /**
     * 低优先级
     */
    public static final int PRIORITY_LOW = -1;
    /**
     * 普通优先级
     */
    public static final int PRIORITY_NORMAL = 0;
    /**
     * 中等优先级
     */
    public static final int PRIORITY_MIDDLE = 1;
    /**
     * 高优先级
     */
    public static final int PRIORITY_HIGH = 2;
    /**
     * 正在发送数据的优先级 在发送的数据优先级蕞诟；
     */
    public static final int PRIORITY_CURR = 10;


    public static final int BLUE_DISCONNECT = 0;
    public static final int BLUE_CONNECTED = 1;
    public static final int BLUE_CONNECTING = 2;
    /*蓝牙连接状态改变*/
    public static final int BLUE_CONNECT_STATE_CHANGE = 6;


    /* 协议的基本定义   一般设备都遵循这个命令 */
    public static final int CMD_TYPE_NULL = 0;
    public static final int CMD_SPECIAL_START_TYPE = 1;
    public static final int CMD_SEND_TYPE = 2;
    public static final int CMD_SEND_NO_ACK_TYPE = 3;
    public static final int CMD_REQUEST_TYPE = 4;
    public static final int CMD_ACK_TYPE = 5;//  设备侧的ACK
    public static final int CMD_SPECIAL_END_TYPE = 250;

    /**
     * app回复设备侧的APC命令  (APP端的代替命令)
     */
    public static final int CMD_APP_ACK_TYPE = -10001; // 蓝牙协议和队列间的ACK  这个是设备发送数据完成，转化成一个CEDevData后需要回复设备侧的Ack命令
    /**
     *
     * 设备侧回复APP的ACK命令
     * App端 通用的Ack 值
     * 需要在协议里面统一转换
     */
    public static class AckApp {
        public static final byte CMD_ACK = -99; //
        public static final byte ACK_TYPE_NULL = -100;
        public static final byte ACK_TYPE_SUCCESS = -101;        //正确应答
        public static final byte ACK_TYPE_WRONG = -102;        //错误应答，命令包的格式不正确
        public static final byte ACK_TYPE_CRC16_WRONG = -103; //CRC校验出错，数据不对
        public static final byte ACK_TYPE_OVER = -104; //队列已满，请求命令包需等待一会再发送
    }


    /* k1  命令 */
    /* 发送用户信息*/
    public static final int K1_DATA_TYPE_USERINFO = 102;
    /* 同步设置*/
    public static final int K1_DATA_TYPE_SETTING = 103;
    /* 同步时间*/
    public static final int K1_DATA_TYPE_SYCN_TIME = 104;
    /* 同步闹钟*/
    public static final int K1_DATA_TYPE_ALARM = 105;

    /* 请求设备信息*/
    public static final short K1_DATA_TYPE_DEVINFO = 3;
    /* 请求用户信息 */
    public static final short K1_DATA_TYPE_BATTERY_INFO = 4;


    public static class K3 {
        /**
         * K3
         */
        public static final short DATA_TYPE_NULL = 0;
        public static final short DEV_TO_APP_START_TYPE = 1;
        public static final short DATA_TYPE_BLE_CHANNEL_REGISTER = 2;
        public static final short DATA_TYPE_DEVINFO = 3;
        public static final short DATA_TYPE_BATTERY_INFO = 4;
        public static final short DATA_TYPE_SPORT = 5;
        public static final short DATA_TYPE_SLEEP = 6;
        public static final short DATA_TYPE_HEART = 7;
        public static final short DATA_TYPE_DEV_SYNC = 8;
        public static final short DATA_TYPE_MIX_SPORT = 9;
        public static final short DATA_TYPE_FIND_PHONE = 10;
        public static final short DATA_TYPE_PHONE_BOOK_UP = 11;
        public static final short DATA_TYPE_BLE_PAIR_STATUS = 12;
        public static final short DATA_TYPE_MUSIC_CONTROL = 13;
        public static final short DATA_TYPE_CURRENT_HEART = 14;
        public static final short DATA_TYPE_OTA_STATUS = 15;
        public static final short DATA_TYPE_PHONE_CONTROL = 16;
        public static final short DATA_TYPE_NFC_ACK = 17;                    // 雷森APK透传, Dev->App
        public static final short DATA_TYPE_NFC_DEV_INFO = 18;                    // 雷森APK透传, Dev->App
        public static final short DATA_TYPE_USER_CHANGE = 19;  // 需要更新提醒


        public static final short DEV_TO_APP_END_TYPE = 100;                 //
        public static final short APP_TO_DEV_START_TYPE = 101;               //
        public static final short DATA_TYPE_USERINFO = 102;                  // 用户信息
        public static final short DATA_TYPE_SETTING = 103;                   // 设置
        public static final short DATA_TYPE_TIME = 104;                      // 时间
        public static final short DATA_TYPE_WEATHER = 105;                   // 天气
        public static final short DATA_TYPE_ALARM = 106;                     // 闹钟
        public static final short DATA_TYPE_MESSAGE_NOTICE = 107;            // 短信/来电/QQ等 通知
        public static final short DATA_TYPE_PAIR_CONNECT = 108;              // 配对
        public static final short DATA_TYPE_APP_CLOSE = 109;                 // 未使用
        public static final short DATA_TYPE_SET_GSEND = 110;                 // 开关数据传输
        public static final short DATA_TYPE_APP_SYNC = 111;                  // 混杂数据同步
        public static final short DATA_TYPE_PAIR_FINISH = 112;               // 配对完成
        public static final short DATA_TYPE_PHONE_BOOK_DOWN = 113;           // 发送联系人
        public static final short DATA_TYPE_SET_TARGET = 114;                // 设置目标
        public static final short DATA_TYPE_OPEN_BLE_PAIR = 115;             // IOS用的Android不用
        public static final short DATA_TYPE_PHONE_BOOK_TRANSFER_CANCEL = 116;// 取消联系人传输
        public static final short DATA_TYPE_MUSIC_CONTENT = 117;             // 音乐内容
        public static final short DATA_TYPE_WATCHFACE_MENU_SELECT = 118;     // 设置表盘
        public static final short DATA_TYPE_MUSIC_APP_CMD = 119;             // 音乐播放状态
        public static final short DATA_TYPE_OTA_DATA = 120;                  // OTA
        public static final short DATA_TYPE_PHONE_CONTROL_TO_DEVICE = 121;   // 接听/挂断 通知
        public static final short DATA_TYPE_MESSAGE_CONTROL = 122;   // 短信控制
        public static final short DATA_TYPE_USER_CARD = 123;   // 名片
        public static final short DATA_TYPE_NFC_CMD = 124;                   // 雷森APK透传, App->Dev
        public static final short DATA_TYPE_NOTE_REMIND = 125;  // 日历提醒


        public static final short DATA_TYPE_MAIN_WATCHFACE = 198;            // 这个设备侧还没有实现
        public static final short APP_TO_DEV_END_TYPE = 200;

        //k3蓝牙传输剩余多少包
        public static final String ACTION_ANIMATION_FOR_REMAIN_BLOCK = "ACTION_ANIMATION_FOR_REMAIN_BLOCK_K3";
    }


    public static String byte2hex(byte[] buffer) {
        String h = "";
        if (buffer == null) {
            return "null";
        }

        for (int i = 0; i < buffer.length; i++) {
            String temp = Integer.toHexString(buffer[i] & 0xFF);
            if (temp.length() == 1) {
                temp = "0" + temp;
            }
            h = h + " " + temp;
        }

        return h;
    }


    public static class K2 {
        public static final short CMD_TYPE_NULL = 0;
        public static final short CMD_TYPE_SEND = 1;    //发送命令
        public static final short CMD_TYPE_SEND_NO_ACK = 2;    //无应答的发送命令
        public static final short CMD_TYPE_REQUEST = 3;//请求命令
        public static final short CMD_TYPE_ACK = 4;    //应答命令


        /* 1.dev to app cmd (1-100) */
        public static final int DEV_TO_APP_START_TYPE = 1;
        public static final int DATA_TYPE_DEVINFO = 2;
        public static final int DATA_TYPE_BATTERY_INFO = 3;
        public static final int DATA_TYPE_REAL_SPORT = 4;
        public static final int DATA_TYPE_HISTORY_SPORT = 5;
        public static final int DATA_TYPE_SLEEP = 6;
        public static final int DATA_TYPE_REAL_HEART = 7;
        public static final int DATA_TYPE_HISTORY_HEART = 8;
        public static final int DATA_TYPE_REAL_GPS = 9;
        public static final int DATA_TYPE_HISTORY_GPS = 10;
        public static final int DATA_TYPE_DEV_SYNC = 11;
        public static final int DATA_TYPE_MIX_SPORT = 12;
        public static final int DATA_TYPE_FIND_PHONE = 13;
        public static final int DATA_TYPE_PHONE_BOOK_UP = 14;
        public static final int DATA_TYPE_BLE_PAIR_STATUS = 15;
        public static final int DATA_TYPE_OTA_STATUS = 16;
        public static final int DATA_TYPE_USER_CHANGE = 17;
        public static final int DATA_TYPE_PHOTOGRAPH = 18;
        public static final int DATA_TYPE_MUSIC_CONTROL = 19;
        public static final int DEV_TO_APP_END_TYPE = 100;

        /* 2.app to dev cmd (101-200) */
        public static final int APP_TO_DEV_START_TYPE = 101;
        public static final int DATA_TYPE_USERINFO = 102; //发送用户信息
        public static final int DATA_TYPE_SETTING = 103;
        public static final int DATA_TYPE_TIME = 104;
        public static final int DATA_TYPE_WEATHER = 105;
        public static final int DATA_TYPE_ALARM = 106;
        public static final int DATA_TYPE_MESSAGE_NOTICE = 107;
        public static final int DATA_TYPE_APP_CLOSE = 108;
        public static final int DATA_TYPE_SET_DATA_SWITCH = 109;
        public static final int DATA_TYPE_APP_SYNC = 110;
        public static final int DATA_TYPE_PAIR_FINISH = 111;
        public static final int DATA_TYPE_PHONE_BOOK_DOWN = 112;
        public static final int DATA_TYPE_SET_TARGET = 113;
        public static final int DATA_TYPE_OPEN_BLE_PAIR = 114;
        public static final int DATA_TYPE_PHONE_BOOK_TRANSFER_CANCEL = 115;
        public static final int DATA_TYPE_WATCHFACE_MENU_SELECT = 116;
        public static final int DATA_TYPE_OTA_DATA = 117;
        public static final int DATA_TYPE_USER_CARD = 118;
        public static final int DATA_TYPE_NOTE_REMIND = 119;
        public static final int DATA_TYPE_MUSIC_CONTENT = 120;
        public static final int DATA_TYPE_GPS_ARGUMENT = 121;


//     public static final int  APP_TO_DEV_START_TYPE =101;
//     public static final int  DATA_TYPE_USERINFO=102;
//     public static final int  DATA_TYPE_SETTING=103
//     public static final int  DATA_TYPE_TIME=104
//     public static final int  DATA_TYPE_WEATHER=105
//     public static final int  DATA_TYPE_ALARM=106
//     public static final int  DATA_TYPE_MESSAGE_NOTICE=107
//     public static final int  DATA_TYPE_APP_CLOSE=108
//     public static final int  DATA_TYPE_SET_DATA_SWITCH=109
//     public static final int  DATA_TYPE_APP_SYNC=110
//     public static final int  DATA_TYPE_PAIR_FINISH=111
//     public static final int  DATA_TYPE_PHONE_BOOK_DOWN=112
//     public static final int  DATA_TYPE_SET_TARGET=113
//     public static final int  DATA_TYPE_OPEN_BLE_PAIR=114
//     public static final int  DATA_TYPE_PHONE_BOOK_TRANSFER_CANCEL=115
//     public static final int  DATA_TYPE_WATCHFACE_MENU_SELECT=116
//     public static final int  DATA_TYPE_OTA_DATA=117
//     public static final int  DATA_TYPE_USER_CARD=118
//     public static final int  DATA_TYPE_NOTE_REMIND=119
//     public static final int  DATA_TYPE_MUSIC_CONTENT=120
//     public static final int  APP_TO_DEV_END_TYPE = 200;



	    /* 3.No use (201-255) */


        public static class CMD {
            public static final short ACK_TYPE_NULL = 0;
            public static final short ACK_TYPE_SUCCESS = 1;    //正确应答
            public static final short ACK_TYPE_WRONG = 2;//错误应答，命令包的格式不正确
            public static final short ACK_TYPE_CRC16_WRONG = 3;  //CRC校验出错，数据不对
            public static final short ACK_TYPE_OVER = 4;//队列已满，请求命令包需等待一会再发送

        }

    }


    /**
     *  k6 的 cmd_type_* 和 k2 的cmd_type_* 一样
     *  k6 的 ACK_TYPE_* 和 k2 的ACK_TYPE_* 一样
     */
    public static class K6 {
        public static final short CMD_TYPE_NULL = 0;
        public static final short CMD_TYPE_SEND = 1;    //发送命令
        public static final short CMD_TYPE_SEND_NO_ACK = 2;    //无应答的发送命令
        public static final short CMD_TYPE_REQUEST = 3;//请求命令
        public static final short CMD_TYPE_ACK = 4;    //应答命令


        /* 1.dev to app cmd (1-100) */
        public static final int DEV_TO_APP_START_TYPE = 1;
        public static final int DATA_TYPE_DEVINFO = 2;
        public static final int DATA_TYPE_BATTERY_INFO = 3;
        public static final int DATA_TYPE_REAL_SPORT = 4;
        public static final int DATA_TYPE_HISTORY_SPORT = 5;
        public static final int DATA_TYPE_SLEEP = 6;
        public static final int DATA_TYPE_REAL_HEART = 7;
        public static final int DATA_TYPE_HISTORY_HEART = 8;
        public static final int DATA_TYPE_REAL_GPS = 9;
        public static final int DATA_TYPE_HISTORY_GPS = 10;
        public static final int DATA_TYPE_DEV_SYNC = 11;
        public static final int DATA_TYPE_MIX_SPORT = 12;
        public static final int DATA_TYPE_FIND_PHONE = 13;
        public static final int DATA_TYPE_BLE_PAIR_STATUS = 14;
        public static final int DATA_TYPE_OTA_STATUS = 15;
        public static final int DATA_TYPE_USER_CHANGE = 16;
        public static final int DATA_TYPE_PHOTOGRAPH = 17;
        public static final int DATA_TYPE_MUSIC_CONTROL = 18;
        public static final int DEV_TO_APP_END_TYPE = 100;


        /* 2.app to dev cmd (101-200) */
        public static final int APP_TO_DEV_START_TYPE = 101;
        public static final int DATA_TYPE_USERINFO = 102; //发送用户信息
        public static final int DATA_TYPE_SETTING = 103;
        public static final int DATA_TYPE_TIME = 104;
        public static final int DATA_TYPE_WEATHER = 105;
        public static final int DATA_TYPE_ALARM = 106;
        public static final int DATA_TYPE_MESSAGE_NOTICE = 107;
        public static final int DATA_TYPE_APP_CLOSE = 108;
        public static final int DATA_TYPE_SET_DATA_SWITCH = 109;
        public static final int DATA_TYPE_APP_SYNC = 110;
        public static final int DATA_TYPE_PAIR_FINISH = 111;
        public static final int DATA_TYPE_SET_TARGET = 112;
        public static final int DATA_TYPE_OPEN_BLE_PAIR = 113;
        public static final int DATA_TYPE_WATCHFACE_MENU_SELECT = 114;
        public static final int DATA_TYPE_OTA_DATA = 115;
        public static final int DATA_TYPE_MUSIC_CONTENT = 116;
        public static final int DATA_TYPE_GPS_ARGUMENT = 117;
        public static final int DATA_TYPE_PAIR_START = 118;

        public static final int APP_TO_DEV_END_TYPE = 200;

	    /* 3.No use (201-255) */


        public static class CMD {
            public static final short ACK_TYPE_NULL = 0;
            public static final short ACK_TYPE_SUCCESS = 1;    //正确应答
            public static final short ACK_TYPE_WRONG = 2;//错误应答，命令包的格式不正确

            public static final short ACK_TYPE_CRC16_WRONG = 3;  //CRC校验出错，数据不对
            public static final short ACK_TYPE_OVER = 4;//队列已满，请求命令包需等待一会再发送

        }

    }


    public static class TYPE {

        /**
         * 是否需要配对相关数据 0：无配对；1：本地配对；2：蓝牙密码配对
         */
        public static final byte PAIR_CONNECT_NONE = 0;
        public static final byte PAIR_CONNECT_LOCAL = 1;
        public static final byte PAIR_CONNECT_BLUETOOTH = 2;
        public static final byte PAIR_CONNECT_NOSENDINFO = 3;

        public static final int DATA_REMAIN_SEND_SLEEP = 4;
        public static final int DATA_REMAIN_SEND_SPORT = 5;

    }







}
